package iotwisp.school.api.controller.pc_admin.system;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import iotwisp.base.rest.JSONResultDTO;
import iotwisp.base.rest.RestBaseController;
import iotwisp.school.config.IotWispSchoolConfig;

@RestController
@RequestMapping("/api/system/config")
public class SystemController extends RestBaseController {

	@Autowired
	private IotWispSchoolConfig config;

	@PostMapping("/query")
	public ResponseEntity<JSONResultDTO> queryConfig() throws UnsupportedEncodingException {

		Map<String, String> configMap = new HashMap<>();
		configMap.put("fileUrlPrefix", config.getFile().getUrlPrefix());
		configMap.put("wxAppId", config.getWx().getAppId());
		return ResponseEntity.ok(createSuccessResult(configMap));
	}

}
